﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RectanglesPractise
{
    class Rectangle : IComparable<Rectangle>, ICloneable
    {
        private Position position;
        private double width;
        private double height;

        internal Position Position
        {
            get { return position; }
            set { position = value; }
        }

        public double Width
        {
            get { return width; }
            set { width = value; }
        }

        public double Height
        {
            get { return height; }
            set { height = value; }
        }

        public Rectangle()
            : this(new Position(0, 0), 0, 0)
        { 
        }

        public Rectangle(Position position, double width, double height)
        {
            this.Position = position;
            this.Width = width;
            this.Height = height;
        }

        public int CompareTo(Rectangle other)
        {
            double thisArea = this.Width * this.Height;
            double otherArea = other.Width * other.Height;
            return thisArea.CompareTo(otherArea);
        }

        public object Clone()
        {
            Position clonePosition = new Position(this.Position.X, this.Position.Y);
            double cloneWidth = this.Width;
            double cloneHeight = this.Height;
            Rectangle clone = new Rectangle(clonePosition, cloneWidth, cloneHeight);
            return clone;
        }
    }
}
